package unei.net.nio;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.InetSocketAddress;
import java.net.Socket;

/**
 * Created by sunlei on 2015/9/1.
 */
public class BasicNioClient {
    public static void main(String[] args) throws Exception{
        Socket socket=new Socket();
        socket.connect(new InetSocketAddress("localhost",1024));
        BufferedReader reader=new BufferedReader(new InputStreamReader(socket.getInputStream()));
        BufferedWriter writer=new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));

        while(true) {
            writer.write("haha");
            writer.flush();
            String str=reader.readLine();
            System.out.println(str);
        }
    }
}
